
const util = require('../../utils/util.js');
Page({
  data: {
    latitude: 39.909088,
    longitude: 116.397643,
    markers: [],
    b:'',
    date: '',
    show: false,
  },
  onDisplay() {
    this.setData({ show: true });
  },
  onClose() {
    this.setData({ show: false });
  },
  formatDate(date) {
    date = new Date(date);
    return `${date.getMonth() + 1}/${date.getDate()}`;
  },
  onConfirm(event) {
    this.setData({
      show: false,
      date: this.formatDate(event.detail),
    });
  },
  // ccc() {
  //   wx.chooseImage({
  //     success (res) {
  //       console.log('chooseImage')
  //       console.log(res)
  //       wx.getImageInfo({
  //         src: res.tempFilePaths[0],
  //         success (res) {
  //           console.log('getImageInfo')
  //           console.log(res)
  //           console.log(res.width)
  //           console.log(res.height)
  //         }
  //       })
  //     }
  //   })
  // },
  ccc(){
    let _this = this;
    wx.chooseImage({
      count:1,
      success(res){
        wx.getFileSystemManager().readFile({
          filePath:res.tempFilePaths[0],
          encoding:"base64",
          success(res){
            console.log(res)
            _this.setData({
              b:'data:image/png;base64,' + res.data
            })
          }
        })
      }
    })
  },
  ccc2() {
    wx.chooseImage({
      success(res) {
        const tempFilePaths = res.tempFilePaths
        wx.uploadFile({
          url: 'https://example.weixin.qq.com/upload', //仅为示例，非真实的接口地址
          filePath: tempFilePaths[0],
          name: 'file',
          formData: {
            'user': 'test'
          },
          success(res) {
            const data = res.data
            //do something
          }
        })
      }
    })
  },
  onShow() {

    console.log('xinpinshow-show')

    // if (typeof this.getTabBar === 'function' &&
    //   this.getTabBar()) {
    //   this.getTabBar().setData({
    //     selected: 0
    //   })
    // }
  },
  onLoad() {

  },

  onLoad() {
    console.log('xinpinshow')

    // this.setData({
    //   logs: (wx.getStorageSync('logs') || []).map(log => {
    //     return {
    //       date: util.formatTime(new Date(log)),
    //       timeStamp: log
    //     }
    //   })
    // })
  }
})
